<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Title</title>
    <link rel="stylesheet" th:href="@{http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{assets/css/core.css}"/>
    <link rel="stylesheet" th:href="@{assets/css/amazeui.css}"/>
    <link rel="stylesheet" th:href="@{assets/css/menu.css}"/>
    <link rel="stylesheet" th:href="@{assets/css/index.css}"/>
    <link rel="stylesheet" th:href="@{assets/css/admin.css}"/>
    <link rel="stylesheet" th:href="@{assets/css/page/typography.css}"/>
    <link rel="stylesheet" th:href="@{assets/css/page/form.css}"/>
    <link rel="stylesheet" th:href="@{assets/css/component.css}"/>

    <link rel="stylesheet" th:href="@{assets/css/viewer.min.css}"/>


    <link rel="stylesheet" th:href="@{http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css}">
    <link rel="stylesheet" th:href="@{https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css}">
    <script th:src="@{https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js}"></script>
    <script th:src="@{https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js}"></script>


    <!-- Favicons -->
    <link rel="icon" th:href="@{img/favicon.png}"/>
    <link rel="apple-touch-icon" th:href="@{img/apple-touch-icon.png}"/>

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" th:href="@{lib/bootstrap/css/bootstrap.min.css}"/>

    <!--external css-->
    <link rel="stylesheet" th:href="@{lib/font-awesome/css/font-awesome.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{css/zabuto_calendar.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{lib/gritter/css/jquery.gritter.css}"/>

    <link rel="stylesheet" th:href="@{css/style.css}"/>
    <link rel="stylesheet" th:href="@{css/style-responsive.css}"/>
    <script th:src="@{lib/chart-master/Chart.js}"></script>


</head>
<body style="overflow-y:scroll;">
<section id="container">
    <!--header start-->
    <header class="header black-bg" th:replace="headBar::myHeadBar">
    </header>
    <!--header end-->

    <!--sidebar start-->
    <aside th:replace="leftSideBar::myLeftBar">

    </aside>
    <!--sidebar end-->

    <!--right begin-->

    <!--main content start-->
    <section id="main-content">
        <section class="wrapper">
            <h3><i class="fa fa-angle-right"></i> 主题管理</h3>
            <div class="row">
                <div class="col-md-12">
                    <div class="content-panel">
                        <button class="btn btn-sm btn-success" id="viewDeleteTheme" data-toggle="modal"
                                data-target="#deleteThemeModal" style="margin-left: 20px;">已删除列表
                        </button>
                        <table class="am-table am-table-striped am-table-hover table-main"
                               style="border-top: ridge;margin-top: 15px;">
                            <thead>
                            <tr>
                                <th><i class="table-id"></i> ID</th>
                                <th class="table-title"><i class="fa fa-question-circle"></i> 主题名</th>
                                <th><i class="fa fa-bookmark"></i> 厂商</th>
                                <th><i class="fa fa-bookmark"></i> 作者</th>
                                <th><i class="fa fa-bookmark"></i> 上传者</th>
                                <th><i class=" fa fa-edit"></i> 操作</th>
                                <th></th>
                            </tr>
                            </thead>
                            <tbody>

                            <tr th:each="theme : ${themeList}">
                                <td th:text="${themeStat.count}+(${curPage}-1)*${pageSize}"></td>
                                <td class="hidden-phone" th:text="${theme.name}"></td>
                                <td th:text="${theme.factory}"></td>
                                <td th:text="${theme.author}"></td>
                                <td th:text="${theme.uploader}"></td>
                                <td>

                                    <button class="btn btn-success btn-xs detailBtn" style="visibility:hidden"
                                            data-toggle="modal" data-target="#myModal"
                                            th:onclick="'getId('+${theme.id}+')'"><i class="fa fa-eye"> 详情</i>
                                    </button>

                                    <a class="btn btn-success btn-xs detailBtn" style="visibility:hidden"
                                       th:href="@{/updateT}+${theme.id}"><i class="fa fa-pencil"> 编辑</i>
                                    </a>

                                    <a class="btn btn-primary btn-xs downloadBtn" style="visibility:hidden"
                                       th:onclick="'downloadTheme('+${theme.id}+')'"
                                       id="myDownload"><i
                                            class=" fa fa-arrow-down"> 下载</i>
                                    </a>


                                    <button class="btn btn-danger btn-xs deleteBtn" style="visibility:hidden"
                                            th:attr="del_uri=@{/deleteT}+${theme.name}"
                                    ><i class="fa fa-trash-o "> 删除</i>
                                    </button>


                                </td>
                            </tr>

                            </tbody>
                        </table>
                        <div class="span6">
                            <div class="dataTables_paginate paging_bootstrap pagination">
                                <table style="float: right">
                                    <tr>
                                        <td>
                                                        <span th:if="${curPage <=1}">
                                                            <ul class="pager">
                                                              <li><a >首页</a></li>
                                                              <li><a >上一页</a></li>
                                                            </ul>
                                                            <!--<td> 首页</td>

                                                           <td cosplan="2">上一页</td>-->
                                                            </span>

                                    </td>

                                        <td>
                                            <span th:if="${curPage > 1}">
                                                           <ul class="pager">
                                                              <li><a th:href="@{/theme}">首页</a></li>
                                                              <li><a th:href="@{'/theme?curPage='+${curPage-1}}">上一页</a></li>
                                                            </ul>

                                                <!--   <td> <a th:href="@{/theme}">首页</a>

                                                    <td> <a th:href="@{'/theme?curPage='+${curPage-1}}"
                                                            cosplan="2">上一页</a>-->
                                                            </span>
                                        </td>

                                        <td>
                                            <span th:if="${curPage == totalPages}">
                                                           <ul class="pager">
                                                              <li><a >下一页</a></li>
                                                              <li><a >尾页</a></li>
                                                            </ul>

                                                <!--  <td cosplan="2"> 下一页</td>
                                                     <td>尾页</td>-->
                                             </span>

                                        </td>
                                        <td>
                                            <span th:if="${curPage < totalPages}">
                                                            <ul class="pager">
                                                              <li><a th:href="@{'/theme?curPage='+${curPage+1}}">下一页</a></li>
                                                              <li><a th:href="@{'/theme?curPage='+${totalPages}}">尾页</a></li>
                                                            </ul>
                                                <!-- <td> <a th:href="@{'/theme?curPage='+${curPage+1}}"
                                                         cosplan="2">下一页</a></td>

                                                 <td> <a th:href="@{'/theme?curPage='+${totalPages}}">尾页</a></td>-->
                                                               </span>
                                        </td>

                                    </tr>
                                </table>

                            </div>

                        </div>
                        <div style="margin-left: 20px;float: left;margin-top: 32px;color: #101010;">
                            共 <span th:text="${totalRows}"></span> 条记录
                            当前是第<span th:text="${curPage}"></span>页
                        </div>
                    </div>
                </div>
                <!-- /content-panel -->
            </div>

            <!-- /col-md-12 -->
            <!-- /row -->
        </section>
    </section>
    <!-- /MAIN CONTENT -->


    <form id="deleteForm" method="get" action="">
        <input type="hidden" name="_method" value="delete">
    </form>

    <form id="downloadForm" method="get" action="">
        <input type="hidden" name="_method" value="download">
    </form>

    <form id="rebackForm" method="get" action="">
        <input type="hidden" name="_method" value="reback">
    </form>
    <!--right end-->
    <!--删除列表模态框-->

    <div class="modal fade" id="deleteThemeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">已删除的主题</h4>
                </div>
                <div class="modal-body">
                    <table class="table">
                        <thead>
                        <tr>
                            <th>
                                编号
                            </th>
                            <th>
                                名称
                            </th>
                            <th>
                                操作
                            </th>

                        </tr>
                        </thead>
                        <tbody>
                        <tr th:each="del_theme : ${del_themeList}">
                            <td th:text="${del_themeStat.count}">
                            </td>
                            <td class="hidden-phone" th:text="${del_theme.name}"></td>
                            <td>
                                <button class="btn btn-sm btn-success backBtn" id="reback" th:attr="reb_uri=@{/rebackT}+${del_theme.name}">恢复
                                </button>
                            </td>
                        </tr>

                        </tbody>
                    </table>


                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <!-- <button type="button" class="btn btn-primary">提交更改</button>-->
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <!--main content end-->


</section>


<!-- 文本模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel" >主题详情</h4>
            </div>
            <div class="modal-body">

                <div class="">
                    <div class="row clearfix">
                        <div class="col-md-12 column">
                            <div class="row clearfix">
                                <div class="col-md-6 column">
                                    <form role="form">
                                        <div class="form-group">
                                            <label for="themeName">主题名:</label>
                                            <input type="text" name="themeName"
                                                                                     value=""
                                                                                     class="form-control"
                                                                                     id="themeName" readonly
                                                                                     style="
    size: -59px;
">
                                        </div>
                                        <div class="form-group">
                                            <label for="factoryName">厂商:</label><input type="text" name="factoryName"
                                                                                      class="form-control"
                                                                                      id="factoryName" readonly
                                                                                    >
                                        </div>

                                    </form>
                                </div>
                                <div class="col-md-6 column">
                                    <form role="form">
                                        <div class="form-group" style="
    /* margin-right: 70px; */
">
                                            <label for="author">作者:</label><input type="text" name="author"
                                                                                 class="form-control"
                                                                                 id="author" readonly
                                                                                 style="">
                                        </div>
                                        <div class="form-group">
                                            <label for="uploader">上传者:</label><input type="text"
                                                                                    class="form-control"
                                                                                    id="uploader" readonly>
                                        </div>

                                    </form>
                                </div>

                            </div>
                        </div>
                    </div>
                    <div class="row clearfix">
                        <div class="col-md-12 column">
                            <div class="form-group">
                                <label for="description">描述：</label>
                                <textarea class="form-control" name="description" id="description" style="resize:none;height: 80px;" readonly=""></textarea>
                            </div>
                        </div>
                        <div class="col-md-12 column">
                            <div class="form-group">
                                <label>预览图：</label>
                                <img alt="" src=" " style="height: 260px" id="preview">
                            </div>


                        </div>

                    </div>
                </div>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <!-- <button type="button" class="btn btn-primary">提交更改</button>-->
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div><!--模态框end-->


<!-- navbar -->
<a th:href="@{admin-offcanvas}" class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu"
   data-am-offcanvas="{target: '#admin-offcanvas'}"><!--<i class="fa fa-bars" aria-hidden="true"></i>--></a>


<script type="text/javascript" th:src="@{assets/js/jquery-2.1.0.js}"></script>

<script type="text/javascript" th:src="@{assets/js/viewer.min.js}"></script>
<!--<script type="text/javascript" th:src="@{assets/js/app.js}"></script>-->
<script type="text/javascript" th:src="@{assets/js/blockUI.js}"></script>
<!--<script type="text/javascript" th:src="@{assets/js/charts/echarts.min.js}"></script>
<script type="text/javascript" th:src="@{assets/js/charts/indexChart.js}"></script>-->
<script type="text/javascript" th:src="@{assets/js/amazeui.min.js}"></script>

<!--删除权限确认-->
<script type="text/javascript" th:inline="javascript">

    $(".deleteBtn").click(function deleteTheme() {
        if (confirm("确定删除吗")) {
            $("#deleteForm").attr("action", $(this).attr("del_uri")).submit();
            alert("删除成功");
            return false;
        } else {
            return false;
        }
    });

</script>


<!--恢复删除的主题-->
<script type="text/javascript" th:inline="javascript">
    $(".backBtn").click(function rebackTheme() {
        if (confirm("确定恢复吗")) {
            $("#rebackForm").attr("action", $(this).attr("reb_uri")).submit();
            alert("恢复成功");
            return false;
        } else {
            return false;
        }
        /* $("#deleteForm").attr("action", $(this).attr("del_uri")).submit();
         return false;*/
    })

</script>


<!--下载权限验证-->
<script type="text/javascript" th:inline="javascript">

    function downloadTheme(ID) {

        var URL = [[@{
            /checkPermission}]];
            var view = "下载";
            $.ajax({
                type: "get",
                url: URL,
                data: {
                    action: view
                },
                success: function (data) {
                    console.log(data);
                    if (0 < parseInt(data)) {
                        /*下载操作*/
                        $(".myDownload").show()
                        url = "/downloadTheme?id=" + ID;
                        window.location.href = url;
                    }
                }
            });
        }

</script>

<!--主题详情-->
<script type="text/javascript" th:inline="javascript">

    function getId(ID) {
        console.log(ID);
        getTheme(ID);
        getThemePreview(ID);
        /*  $("#id").val(ID);*/

    }

    function getTheme(ID) {
        var URL = [[@{
            /detailT}]];
            $.ajax({
                type: "get",
                url: URL,
                data: {
                    id: ID
                },
                success: function (data) {
                    console.log(data);
                    $("#themeName").val(data.name);
                    $("#factoryName").val(data.factory);
                    $("#author").val(data.author);
                    $("#description").val(data.description);
                    $("#uploader").val(data.uploader);
                }
            });

        }

</script>


<script type="text/javascript" th:inline="javascript">

    function getImgId(ID) {
        console.log(ID);
        getThemePreview(ID);
        /*  $("#id").val(ID);*/

    }

    function getThemePreview(ID) {
        var URL = [[@{
            /previewT}]];
            $.ajax({
                type: "get",
                url: URL,
                data: {
                    id: ID
                },
                success: function (data) {
                    console.log(data);
                    $("#preview").attr("src", "data:image/gif;base64," + data);
                }
            });

        }

</script>


<script type="text/javascript" th:inline="javascript">
    $(function () {
        var URL = [[@{
            /headPic}]];
            $.ajax({
                type: "get",
                url: URL,
                data: {},
                success: function (data) {
                    console.log(data);
                    $("#headPic").attr("src", "data:image/gif;base64," + data);
                }
            });
        }
    );


</script>


<!--验证登陆者的主题主题上传权限-->

<script type="text/javascript" th:inline="javascript">
    $(function () {
        var URL = [[@{
            /checkPermission}]];
            var add = "上传";
            $.ajax({
                type: "get",
                url: URL,
                data: {
                    action: add
                },
                success: function (data) {
                    console.log(data);
                    if (0 < parseInt(data)) {
                        $("#uploadTheme").show();
                    } else {

                        $("#uploadTheme").hide();
                    }
                }
            });
        }
    )


</script>

<!--验证登陆者的主题主题查看权限-->

<script type="text/javascript" th:inline="javascript">
    $(function () {
        var URL = [[@{
            /checkPermission}]];
            var view = "查看";
            $.ajax({
                type: "get",
                url: URL,
                data: {
                    action: view
                },
                success: function (data) {
                    console.log(data);
                    if (0 < parseInt(data)) {
                        $("#viewTheme").show()
                    } else {

                        $("#viewTheme").hide()
                    }
                }
            });
        }
    )


</script>


<!--验证登陆者的主题主题删除权限-->
<script type="text/javascript" th:inline="javascript">
    $(function () {
        var URL = [[@{
            /checkPermission}]];
            var view = "删除";
            $.ajax({
                type: "get",
                url: URL,
                data: {
                    action: view
                },
                success: function (data) {
                    console.log(data);
                    if (0 < parseInt(data)) {

                        $(".deleteBtn").css('visibility', 'visible');
                        $(".detailBtn").css('visibility', 'visible');
                        //window.location.href = "/theme";
                    } else {
                        $(".deleteBtn").hide()
                        // alert("对不起，您没有此权限！");
                    }
                }
            });
        }
    )


</script>


<!--验证登陆者的主题主题下载权限-->

<script type="text/javascript" th:inline="javascript">
    $(function () {
        var URL = [[@{
            /checkPermission}]];
            var add = "下载";
            $.ajax({
                type: "get",
                url: URL,
                data: {
                    action: add
                },
                success: function (data) {
                    console.log(data);
                    if (0 < parseInt(data)) {
                        $(".downloadBtn").css('visibility', 'visible');
                        $(".detailBtn").css('visibility', 'visible');
                    } else {

                        $(".downloadBtn").hide();
                    }
                }
            });
        }
    )


</script>


<!--验证角色-->
<script type="text/javascript" th:inline="javascript">
    $(function () {
        var URL = [[@{
            /checkRole}]];
            $.ajax({
                type: "get",
                url: URL,
                data: {},
                success: function (data) {
                    console.log(data);
                    if (0 < parseInt(data)) {
                        var url = [[@{
                            /user}]]
                            $("#myUser").html('<a href="' + url + '" >\n' +
                                '                        <i class="fa fa-desktop"></i>\n' +
                                '                        <span >用户管理</span>\n' +
                                '                    </a>');
                            $(".detailBtn").css('visibility', 'visible');
                        }
                    else
                        {
                        }
                    }
                });
        }
    )


</script>


<!-- js placed at the end of the document so the pages load faster -->
<script th:src="@{lib/jquery/jquery.min.js}"></script>

<script th:src="@{lib/bootstrap/js/bootstrap.js}"></script>
<script class="include" type="text/javascript" th:src="@{lib/jquery.dcjqaccordion.2.7.js}"></script>
<script th:src="@{lib/jquery.scrollTo.min.js}"></script>
<script th:src="@{lib/jquery.nicescroll.js}" type="text/javascript"></script>
<script th:src="@{lib/jquery.sparkline.js}"></script>
<!--common script for all pages-->
<script th:src="@{lib/common-scripts.js}"></script>
<script type="text/javascript" th:src="@{lib/gritter/js/jquery.gritter.js}"></script>
<script type="text/javascript" th:src="@{lib/gritter-conf.js}"></script>
<!--script for this page-->
<script th:src="@{lib/sparkline-chart.js}"></script>
<script th:src="@{lib/zabuto_calendar.js}"></script>


<script type="text/javascript" th:inline="javascript">
    $(function () {
        var URL = [[@{
            /headPic}]];
            $.ajax({
                type: "get",
                url: URL,
                data: {},
                success: function (data) {
                    console.log(data);
                    $("#headPic").attr("src", "data:image/gif;base64," + data);
                }
            });
        }
    );


</script>


</body>
</html>